<template>
	<view class="card-page">
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view style="height: 20rpx;"></view>
			<view class="card-list">
				<view class="card-item" v-for="(item,index) in dataList" :key="index"
					@click="$Tips('/pages/merchant/couponDetail?coupon_id='+item.id+'&page=receive')">
					<view class="item-left active">
						<view class="coupon-top top-active">平台通用</view>
						<view class="coupon-money">
							<text class=" coupon-unit">¥</text>{{item.number}}
						</view>
						<view class="coupon-rule" v-if="item.money!=0">满{{item.money}}可用</view>
						<view class="coupon-rule" v-else>无门槛</view>
					</view>
					<view class="item-center">
						<view class="item-title">{{item.name}}</view>
						<view class="item-type">到期时间:{{item.endtime}}</view>
						<view class="item-time">
							<view class="label">使用说明</view>
							<u-icon name="arrow-down" size="12"></u-icon>
						</view>
					</view>
					<view class="item-right">
						<view class="use">领取</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
			}
		},
		methods: {
			queryList(pageNo, pageSize) {
				this.$Api.common.getCouponList({
					page: pageNo,
					limit: pageSize,
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				}).catch(res => {
					this.$refs.paging.complete(false);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card-page {
		width: 100%;
		min-height: 100vh;
		background: #F6F6F8;

		.card-list {
			margin: 0rpx 30rpx;

			.card-item {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;
				box-sizing: border-box;
				box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.1), inset 0rpx 2rpx 2rpx 0rpx #FFFFFF;
				border-radius: 28rpx;
				background: #ffffff;
				overflow: hidden;

				.item-left {
					width: 180rpx;
					height: 228rpx;
					margin-right: 20rpx;
					background-color: #d6d6d6;
					color: #FFFFFF;

					.coupon-top {
						font-weight: 400;
						font-size: 14px;
						line-height: 21px;
						text-align: center;
						padding: 10rpx 0;
						border-radius: 14px 0px 0px 0px;
					}

					.top-active {
						background: linear-gradient(90deg, #FFE2E2 0%, #FFF3F3 100%);
					}

					.coupon-money {
						font-weight: bold;
						font-size: 26px;
						line-height: 39px;
						text-align: center;
						margin-top: 12rpx;

						.coupon-unit {
							font-weight: bold;
							font-size: 26rpx;
							text-align: center;
						}
					}

					.coupon-rule {
						margin-top: 12rpx;
						font-weight: 400;
						font-size: 14px;
						line-height: 21px;
						text-align: center;
					}
				}

				.active {
					background-color: #fff3f3;
					color: #FF1E00;
				}

				.item-center {
					flex: 1;
					height: 228rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;

					.item-title {
						font-weight: bold;
						font-size: 32rpx;
					}

					.item-type {
						font-size: 26rpx;
						color: #565656;
						margin-top: 16rpx;
					}

					.item-time {
						display: flex;
						align-items: center;
						font-size: 26rpx;
						color: #565656;
						margin-top: 16rpx;
						.label{
							margin-right: 10rpx;
						}
					}
				}

				.item-right {
					margin-right: 20rpx;

					.use {
						width: 112rpx;
						height: 52rpx;
						background: linear-gradient(270deg, #FE4369 0%, #FE746D 100%);
						border-radius: 100rpx;
						font-size: 24rpx;
						color: #FFFFFF;
						text-align: center;
						line-height: 52rpx;
					}
				}
			}
		}
	}
</style>